package com.ruiysoft.pub.core;

/**
 * 响应结果生成工具
 */
public class ResultGenerator {
    private static final String DEFAULT_SUCCESS_MESSAGE = "SUCCESS";

    public static Result genSuccessResult() {
        return new Result()
            .setBizCode(ResultCode.CODE_SUCCESS)
            .setBizMessage(DEFAULT_SUCCESS_MESSAGE);
    }

    public static <T> Result<T> genSuccessResult(T data) {
        return new Result<T>()
                .setBizCode(ResultCode.CODE_SUCCESS)
                .setBizMessage(DEFAULT_SUCCESS_MESSAGE)
                .setData(data);
    }

    public static Result genFailResult(String message) {
        return new Result<Void>()
                .setBizCode(ResultCode.CODE_COMMON_ERROR)
                .setBizMessage(message);
    }
    public static Result genAcceptResult(String message) {
        return new Result<Void>()
                .setBizCode(ResultCode.CODE_ACCEPT_ERROR)
                .setBizMessage(message);
    }

    public static Result genExceptionResult(String code,String message) {
        return new Result<Void>()
                .setBizCode(code)
                .setBizMessage(message);
    }
}
